﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace lab05
{
    class MatrixVisualizator
    {
        private IMatrix _matrix;
        private IMatrixDrawer _drawer;

        public virtual IMatrixDrawer Drawer { get { return _drawer; } set { _drawer = value; } }
        public virtual IMatrix Matrix { get { return _matrix; } set { _matrix = value; } }

        public MatrixVisualizator(IMatrix matrix, IMatrixDrawer drawer)
        {
            _matrix = matrix;
            _drawer = drawer;
        }

        public virtual void Visualize()
        {
            DrawBorder(_matrix.GetNumRows(), _matrix.GetNumColumns());
            IMatrixIterator it = _matrix.GetIterator();

            while (!it.IsDone)
            {
                DrawCell(it.Current.I, it.Current.J);
                DrawValue(it.Current.I, it.Current.J, it.Current.Value);
                it.Next();
            }
        }

        public virtual void DrawBorder(int M, int N)
        {
            Drawer.DrawBorder(M, N);
        }

        public virtual void DrawCell(int i, int j)
        {
            Drawer.DrawCell(i, j);
        }

        public virtual void DrawValue(int i, int j, int value)
        {
            Drawer.DrawValue(i, j, value);
        }
    }
}
